<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>注册</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/css/nprogress.css">
    <link rel="stylesheet" type="text/css" href="/static/css/style.css">
    <link rel="stylesheet" type="text/css" href="/static/css/font-awesome.min.css">
    <link rel="apple-touch-icon-precomposed" href="/static/images/icon.png">
    <link rel="shortcut icon" href="/static/images/favicon.ico">
    <script src="/static/js/jquery-2.1.4.min.js"></script>
    <script src="/static/js/nprogress.js"></script>
    <script src="/static/js/jquery.lazyload.min.js"></script>
    <!--[if gte IE 9]>
    <script src="/static/js/jquery-1.11.1.min.js" type="text/javascript"></script>
    <script src="/static/js/html5shiv.min.js" type="text/javascript"></script>
    <script src="/static/js/respond.min.js" type="text/javascript"></script>
    <script src="/static/js/selectivizr-min.js" type="text/javascript"></script>
    <![endif]-->
    <!--[if lt IE 9]>
    <script>window.location.href='upgrade-browser.html';</script>
    <![endif]-->
</head>
<body class="user-select">
<header class="header">
        <nav class="navbar navbar-default" id="navbar">
            <div class="container">
                <div class="collapse navbar-collapse" id="header-navbar">
                    <ul class="nav navbar-nav navbar-right">
                        <li><a data-cont="首页" title="首页" href="/">首页</a></li>
                        <li><a data-cont="热门话题" title="热门话题" href="/topic/list.html">热门话题</a></li>
                        <li><a data-cont="注册" title="注册" href="/user/register.html">注册</a></li>
                        <li><a data-cont="登录" title="登录" href="/user/login.html">登录</a></li>
                        <li><a data-cont="发布" title="发布" href="/weibo/publish.html">发布</a></li>
                    </ul>
                </div>
            </div>
        </nav>
</header>
<section class="container">
    <div class="content-wrap">
        <div class="content">
            <h3 class="form-title">用户注册</h3>
            <div class="form-group">
                <label class="control-label">登录名</label>
                <div>
                    <input class="form-control" type="text" placeholder="请输入对应的登录用户名" name="loginName" id="loginName"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">登录密码</label>
                <div>
                    <input class="form-control" type="password" placeholder="请输入对应的登录用户的密码" name="password" id="password"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">用户昵称</label>
                <div>
                    <input class="form-control" type="text" placeholder="请输入对应的登录用户昵称" name="nickName" id="nickName"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">用户性别</label>
                <div>
                    <input class="form-control" type="text" placeholder="请输入对应的登录用户性别,男为1，女为2" name="gender" id="gender"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">用户年龄</label>
                <div>
                    <input class="form-control" type="text" placeholder="请输入对应的登录用户年龄" name="age" id="age"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">用户头像</label>
                <div>
                    <input class="form-control" type="text" placeholder="请输入对应的登录用户头像的url" name="avatarUrl" id="avatarUrl"/>
                </div>
            </div>
            <div class="form-actions">
                <button class="btn" id="register" type="submit">注册</button>
            </div>
        </div>

    </div>
</section>

</body>

<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/jquery.ias.js"></script>
<script src="/static/js/scripts.js"></script>


<script type="text/javascript">
    jQuery(document).ready(function(){
        $("#register").on("click",function(){
            var loginName=$("#loginName").val();
            var password = $("#password").val();
            var nickName=$("#nickName").val();
            var age = $("#age").val();
            var gender = $("#gender").val();
            var avatarUrl = $("#avatarUrl").val();

            if(loginName == "" || password == "" || nickName == "" || age == "" || gender == "" || avatarUrl == "" ){
                alert("输入缺少必要参数");
                return false;
            }
            $.ajax({
                type:"POST",
                contentType:"application/x-www-form-urlencoded",
                url:"/user/register",
                data:{
                    "loginName":loginName,
                    "password":password,
                    "nickName":nickName,
                    "age":age,
                    "gender":gender,
                    "avatarUrl":avatarUrl
                },
                success:function(data){
                    if(data.success){
                        alert("success");
                    }else{
                        alert(data.data);
                    }

                },
                error:function(data){
                    alert("注册失败，原因为"+data.responseText);
                }
            })

        });
    });

</script>
</html>